<link rel="stylesheet" type="text/css" href="js/webuploader/webuploader.css" charset="utf-8" />
<script type="text/javascript" src="js/webuploader/webuploader.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/webuploader/admin.upload.js" charset="utf-8"></script>
<!-- php:$catelist = $app->model('res')->cate_all(); -->

<div class="tips">附件上传</div>
<div style="padding:10px;margin:5px;">
<div class="table">
	<div class="title">
		{lang附件上传：}
		<span class="note">{lang请选择要上传的附件分类}{lang上传的文件上传不能超过：}<span class="red">{func get_cfg_var upload_max_filesize}</span></span>
	</div>
	<div class="content">
		<table>
		<tr>
			<td>
				<select id="add_cate_id" onchange="cate_change()">
					<!-- loop from=$catelist key=$key value=$value -->
					<option value="{$value.id}"{if $value.is_default} selected{/if} data="{$value.filetypes}" catename="{$value.title}">
					{$value.title}<!-- if $value.filetypes --> / {lang支持上传格式：}{$value.filetypes}<!-- /if --></option>
					<!-- /loop -->
				</select>
			</td>
			<td><div id="upload_picker" class=""></div></td>
		</tr>
		</table>
	</div>
</div>

<div class="table">
	<div class="content" id="upload_progress"></div>
</div>
</div>
<script type="text/javascript">
var obj_upload = {};
$(document).ready(function(){
	cate_change();
});
function cate_change()
{
	val = $("#add_cate_id").val();
	if(!val){
		$.dialog.alert('请选择要存储的目标分类');
		return false;
	}
	var data = $("#add_cate_id option[value="+val+"]").attr('data');
	var catename = $("#add_cate_id option[value="+val+"]").attr('catename');
	obj_upload = new $.admin_upload({
		"multiple"	: 'false',
		"id" : "upload",
		'pick':{'id':'#upload_picker','multiple':false},
		'resize':false,
		"swf" : "js/webuploader/uploader.swf",
		"server": "{url ctrl=upload func=save/}",
		"filetypes" : "{$rs.ext}",
		'accept' : {'title':catename,'extensions':data},
		"formData" :{'{func session_name}':'{func session_id}','cateid':val},
		'fileVal':'upfile',
		'auto':true,
		"success":function(){
			$.dialog.alert('附件上传成功',function(){
				$.phpok.reload();
			});
		}
	});
}
</script>
